#!-*- coding: utf-8 -*-
import json
import unittest

from mongoengine import connect

from app import create_app


class FlaskTestCase(unittest.TestCase):
    def setUp(self):
        app = create_app(config_name="test")
        self.app = app
        self.test_client = app.test_client()
        # self.init_data()

    def test_consultation(self):
        data = dict(
            name='hello',
            tel='18718572432',
        )

        response = self.test_client.post(
            '/uc/support/consulation/',
            data=data,
            headers=dict(HTTP_VACATION_DEVICE_ID="1111111111")
        )
        result = json.loads(response.data)

        self.assertEqual(response.status, '200 OK')
        self.assertEqual(result.get('code'), 0)

    def init_data(self):
        pass

    def tearDown(self):
        with self.app.app_context():
            # 移除测试数据库
            db = connect(self.db_name)
            db.drop_database(self.db_name)


if __name__ == '__main__':
    unittest.main()